package br.com.timesystem.model;

import java.io.Serializable;
import java.util.UUID;

/**
 *
 * @author duduso
 */
public abstract class EntityBase implements Serializable{

    public abstract Long getId();

    @Override
    public boolean equals(Object arg) {
        if(arg == null){
            return false;
        }
        if(!this.getClass().equals(arg.getClass())){
            return false;
        }
        final EntityBase other = (EntityBase) arg;
        if(this.getId() == null && other.getId() == null){
            return (this.getId() == other.getId());
        }
        if(this.getId() != null && other.getId() == null){
            return false;
        }
        if(this.getId() == null && other.getId() != null){
            return false;
        }
        return this.getId().equals(other.getId());
    }

    @Override
    public int hashCode() {
        return UUID.randomUUID().hashCode();
    }

}
